<?php declare(strict_types=1);

namespace App\Services\ElectronicSignature;

use App\Services\ElectronicSignature\Strategy\EasypayElectronicSignatureHandler;
use App\Services\ElectronicSignature\Strategy\ElectronicSignatureInterface;
use App\Services\ElectronicSignature\Strategy\GtxyElectronicSignatureHandler;
use Illuminate\Http\Request;

class Bootstrap
{
    public static function run(Request $request): ElectronicSignatureInterface
    {
        $api = $request->post("api", "easypay");
        switch ($api) {
            case "easypay":
                $handler = new EasypayElectronicSignatureHandler();
                break;
            case "gtxy":
                $handler = new GtxyElectronicSignatureHandler();
                break;
            default:
                throw new \Exception("签名API不支持");
        }
        return $handler;
    }

}